package ScanLineAlghorithms.RectanglesUnion;

import java.util.LinkedList;

import DataModel.LayoutManager.CEdge;
/**
 * Class models a triple structure for scan line algorithm of calculating rectangle union
 * x - x axis value
 * b - y axis beginning value
 * t - y axis termination value
 * @author Guy
 *
 */
public class Triple implements Comparable{
	
		public long x, b ,t;
		CEdge owner;
		public Triple(long x, long b, long t, CEdge edge) {
			this.x = x;
			this.b = b;
			this.t = t;
			owner = edge;
		}
		
		public void printTriple() {
			System.out.println("x="+x+" : b="+b+" : t="+t);
		}
		public static void ptintTriples(LinkedList<Triple> l) {
			for (Triple t: l) t.printTriple();
		}

		/**
		 * Comparator in order to sort the triples
		 */
		public int compareTo(Object arg0) {
			if (this.b == ((Triple)arg0).b) {
				if(this.x < ((Triple)arg0).x ) { 
					return -1;
				}
				if(this.x == ((Triple)arg0).x ) { 
					return 0;
				}
				if(this.x > ((Triple)arg0).x ) { 
					return 1;
				}
				
			}
				
			if (this.b < ((Triple)arg0).b) return -1;
			
			return 1;
		}
}	
